package com.dmooo.yxmmerchant.wxapi;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.common.util.SPUtils;
import com.common.util.ToastUtil;
import com.dmooo.yxmmerchant.app.YZXApplication;
import com.tencent.mm.opensdk.constants.ConstantsAPI;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;

public class WXPayEntryActivity extends Activity implements IWXAPIEventHandler {

    private static final String TAG = "MicroMsg.SDKSample.WXPayEntryActivity";


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        YZXApplication.getIwxapi().handleIntent(getIntent(), this);
    }

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        setIntent(intent);
        YZXApplication.getIwxapi().handleIntent(intent, this);
    }

    @Override
    public void onReq(BaseReq req) {
    }

    @Override
    public void onResp(BaseResp resp) {
        if (resp.getType() == ConstantsAPI.COMMAND_PAY_BY_WX) {
            if(resp.errCode==0){
                SPUtils.put(this,"pay","1");
            }else{
                ToastUtil.getInstance().showErrorMsg("支付失败");
            }
        }
        finish();
        finish();
    }
}